<!DOCTYPE HTML>
<html lang="zh-CN">
<head>
    

<head><meta name="generator" content="Hexo 3.8.0">
    <meta charset="utf-8">
    <meta name="keywords" content="多线程, Zhou•Yong">
    <meta name="description" content="多线程 C#支持通过多线程并行地执行代码，一个线程有它独立的执行路径，能够与其它的线程同时地运行。一个C#程序开始于一个单线程，这个单线程是被CLR和操作系统（也称为“主线程”）自动创建的，并具有多线程创建额外的线程。
进程  Proces">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit|ie-stand|ie-comp">
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <title>多线程 | Zhou•Yong</title>
    <link rel="icon" type="image/png" href="/favicon.png">

    <link rel="stylesheet" type="text/css" href="/libs/awesome/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/materialize/css/materialize.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/aos/aos.css">
    <link rel="stylesheet" type="text/css" href="/libs/animate/animate.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/lightGallery/css/lightgallery.min.css">
    <link rel="stylesheet" type="text/css" href="/css/matery.css">
    <link rel="stylesheet" type="text/css" href="/css/my.css">

    <script src="/libs/jquery/jquery-2.2.0.min.js"></script>
<link rel="stylesheet" href="/css/prism-tomorrow.css" type="text/css"></head>

</head>

<body>

<header class="navbar-fixed">
    <nav id="headNav" class="bg-color nav-transparent">
        <div id="navContainer" class="container">
            <div class="nav-wrapper">
                <div class="brand-logo">
                    <a href="/" class="waves-effect waves-light">
                        
                        <img src="/medias/logo.png" class="logo-img hide-on-small-only">
                        
                        <span class="logo-span">Zhou•Yong</span>
                    </a>
                </div>
                <a href="#" data-activates="mobile-nav" class="button-collapse"><i class="fa fa-navicon"></i></a>
<ul class="right">
    
    <li class="hide-on-med-and-down">
        <a href="/" class="waves-effect waves-light">
            
            <i class="fa fa-home"></i>
            
            <span>主页</span>
        </a>
    </li>
    
    <li class="hide-on-med-and-down">
        <a href="/about" class="waves-effect waves-light">
            
            <i class="fa fa-user-circle-o"></i>
            
            <span>个人介绍</span>
        </a>
    </li>
    
    <li class="hide-on-med-and-down">
        <a href="/categories" class="waves-effect waves-light">
            
            <i class="fa fa-bookmark"></i>
            
            <span>分类</span>
        </a>
    </li>
    
    <li class="hide-on-med-and-down">
        <a href="/tags" class="waves-effect waves-light">
            
            <i class="fa fa-tags"></i>
            
            <span>标签</span>
        </a>
    </li>
    
    <li class="hide-on-med-and-down">
        <a href="/friends" class="waves-effect waves-light">
            
            <i class="fa fa-address-book"></i>
            
            <span>推荐</span>
        </a>
    </li>
    
    <li>
        <a id="toggleSearch" class="waves-effect waves-light">
            <i id="searchIcon" class="mdi-action-search"></i>
        </a>
    </li>

</ul>

<div class="side-nav" id="mobile-nav">

    <div class="mobile-head bg-color">
        
        <img src="/medias/logo.png" class="logo-img circle responsive-img">
        
        <div class="logo-name">Zhou•Yong</div>
        <div class="logo-desc">
            
            你迈出的步伐不非得很大，只要你是在正确的方向前进就行
            
        </div>
    </div>

    <ul class="menu-list mobile-menu-list">
        
        <li>
            <a href="/" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-home"></i>
                
                主页
            </a>
        </li>
        
        <li>
            <a href="/about" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-user-circle-o"></i>
                
                个人介绍
            </a>
        </li>
        
        <li>
            <a href="/categories" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-bookmark"></i>
                
                分类
            </a>
        </li>
        
        <li>
            <a href="/tags" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-tags"></i>
                
                标签
            </a>
        </li>
        
        <li>
            <a href="/friends" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-address-book"></i>
                
                推荐
            </a>
        </li>
        
        
    </ul>

    <div class="social-link"><a href="#!" class="tooltipped" data-tooltip="邮件联系我: zy20081@126.com" data-position="top" data-delay="50">
    <i class="fa fa-envelope-open"></i>
</a>
<a href="#!" class="tooltipped" data-tooltip="QQ联系我: 314153271" data-position="top" data-delay="50">
    <i class="fa fa-qq"></i>
</a>

<a href="/atom.xml" class="tooltipped" target="_blank" data-tooltip="RSS 订阅" data-position="top" data-delay="50">
    <i class="fa fa-rss"></i>
</a>
</div>
</div>

            </div>
        </div>

        
    </nav>
</header>





<div class="bg-cover post-cover" style="background-image: url('/medias/featureimages/22.jpg')">
    <div class="container">
        <div class="row">
            <div class="col s12 m12 l12">
                <div class="brand">
                    <div class="description center-align post-title">
                        多线程
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>



<main class="post-container content">

    
    <link rel="stylesheet" href="/libs/tocbot/tocbot.css">
<style>
    #articleContent h1,
    #articleContent h2,
    #articleContent h3,
    #articleContent h4,
    #articleContent h5,
    #articleContent h6 {
        padding-top: 76px;
        margin-top: -76px;
    }

    #articleContent h1 {
        line-height: 3.5rem;
    }

    #articleContent h2 {
        line-height: 3.2rem;
    }

    #articleContent h3 {
        line-height: 2.8rem;
    }

    #articleContent h4 {
        line-height: 2.5rem;
    }

    #articleContent h5 {
        line-height: 2.2rem;
    }

    #articleContent h6 {
        line-height: 1.9rem;
    }

    #articleContent :focus {
        outline: none;
    }

    .toc-fixed {
        position: fixed;
        top: 64px;
    }

    .toc-widget {
        padding-left: 20px;
    }

    .toc-widget .toc-title {
        margin: 35px 0 15px 0;
        padding-left: 17px;
        font-size: 1.5rem;
        font-weight: bold;
        line-height: 1.5rem;
    }

    .toc-widget ol {
        padding: 0;
        list-style: none;
    }

    #toc-content ol {
        padding-left: 10px;
    }

    #toc-content ol li {
        padding-left: 10px;
    }

    #toc-content .toc-link:hover {
        color: #42b983;
        font-weight: 700;
        text-decoration: underline;
    }

    #toc-content .toc-link::before {
        background-color: transparent;
        max-height: 25px;
    }

    #toc-content .is-active-link {
        color: #42b983;
    }

    #toc-content .is-active-link::before {
        background-color: #42b983;
    }
</style>
<div class="row">
    <div class="col s12 m12 l9">
        <!-- 文章内容详情 -->
<div id="artDetail">
    <div class="card">
        <div class="card-content article-info">
            
            <div class="article-tag">
                
                <a href="/tags/C-基础知识/" target="_blank">
                    <span class="chip bg-color">C# 基础知识</span>
                </a>
                
                <a href="/tags/C/" target="_blank">
                    <span class="chip bg-color">C#</span>
                </a>
                
            </div>
            
            <div class="post-info">
                
                <span class="post-cate">
                    <i class="fa fa-bookmark fa-fw icon-category"></i>
                    
                    <a href="/categories/C/" class="post-category" target="_blank">
                        C#
                    </a>
                    
                </span>
                

                <span class="post-date">
                    <i class="fa fa-clock-o fa-fw"></i>2019-01-15
                </span>
            </div>
        </div>
        <hr>
        <div class="card-content article-card-content">
            <div id="articleContent">
                <h2 id="多线程"><a href="#多线程" class="headerlink" title="多线程"></a>多线程</h2><p> C#支持通过多线程并行地执行代码，一个线程有它独立的执行路径，能够与其它的线程同时地运行。一个C#程序开始于一个单线程，这个单线程是被CLR和操作系统（也称为“主线程”）自动创建的，并具有多线程创建额外的线程。</p>
<h2 id="进程"><a href="#进程" class="headerlink" title="进程"></a>进程</h2><pre class=" language-bash"><code class="language-bash">  Process press <span class="token operator">=</span> Process.Start<span class="token punctuation">(</span><span class="token string">"iexplore.exe"</span>, <span class="token string">"www.baidu.com"</span><span class="token punctuation">)</span><span class="token punctuation">;</span> //启动一个进程
  var processes <span class="token operator">=</span> Process.GetProcesses<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> //获得本地进程
  foreach <span class="token punctuation">(</span>var item <span class="token keyword">in</span> processes<span class="token punctuation">)</span>
  <span class="token punctuation">{</span>
      Console.WriteLine<span class="token punctuation">(</span>item.ProcessName<span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>

   获取当前进程 睡100秒，在关掉
  Process p <span class="token operator">=</span> Process.GetCurrentProcess<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  Thread.Sleep<span class="token punctuation">(</span>100<span class="token punctuation">)</span><span class="token punctuation">;</span>
  p.Kill<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
<h2 id="应用程序域"><a href="#应用程序域" class="headerlink" title="应用程序域"></a>应用程序域</h2><pre class=" language-bash"><code class="language-bash">  AppDomain.Unload<span class="token punctuation">(</span>AppDomain.CurrentDomain<span class="token punctuation">)</span><span class="token punctuation">;</span> 
    <span class="token keyword">if</span> <span class="token punctuation">(</span>AppDomain.CurrentDomain.IsDefaultAppDomain<span class="token punctuation">(</span><span class="token punctuation">))</span> <span class="token punctuation">{</span>
        Console.WriteLine<span class="token punctuation">(</span><span class="token string">"主应用程序域"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    //自己写个一个应用程序域//创建一个应用程序域
    AppDomainSetup setup <span class="token operator">=</span> new AppDomainSetup<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    setup.LoaderOptimization <span class="token operator">=</span> LoaderOptimization.SingleDomain<span class="token punctuation">;</span>
    AppDomain appDomain <span class="token operator">=</span> AppDomain.CreateDomain<span class="token punctuation">(</span><span class="token string">"MultThread"</span>, null, setup<span class="token punctuation">)</span><span class="token punctuation">;</span>
    appDomain.ExecuteAssembly<span class="token punctuation">(</span><span class="token string">"MultThread.exe"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
<h2 id="线程"><a href="#线程" class="headerlink" title="线程"></a>线程</h2><pre class=" language-bash"><code class="language-bash">   Thread Mainthread <span class="token operator">=</span> Thread.CurrentThread<span class="token punctuation">;</span>
    Console.WriteLine<span class="token punctuation">(</span><span class="token string">"主线程id是：{0}"</span>, Mainthread.ManagedThreadId<span class="token punctuation">)</span><span class="token punctuation">;</span>
    //创建一个线程
    ThreadStart start <span class="token operator">=</span> DoWork<span class="token punctuation">;</span>
    Thread thread <span class="token operator">=</span> new Thread<span class="token punctuation">(</span>start<span class="token punctuation">)</span><span class="token punctuation">;</span>
    thread.Name <span class="token operator">=</span> <span class="token string">"first"</span><span class="token punctuation">;</span>
    //线程的级别:微软对windows 0-31级别,级别是动态的,操作系统只做参考
    thread.Priority <span class="token operator">=</span> ThreadPriority.Normal<span class="token punctuation">;</span>
    //设置后台线程:主线程关闭了，子线程也关闭
    //前台线程:主线程关了， 子线程还在跑着
    thread.IsBackground <span class="token operator">=</span> <span class="token boolean">true</span><span class="token punctuation">;</span>
    //启动线程（不是真正启动,告诉CPU可以启动）
    thread.Start<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">while</span> <span class="token punctuation">(</span>true<span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        Console.WriteLine<span class="token punctuation">(</span><span class="token string">"主线程跑起:{0}"</span>, Thread.CurrentThread.ManagedThreadId<span class="token punctuation">)</span><span class="token punctuation">;</span>
        Thread.Sleep<span class="token punctuation">(</span>1000<span class="token punctuation">)</span><span class="token punctuation">;</span>
        //thread.Abort<span class="token punctuation">(</span>thread<span class="token punctuation">)</span><span class="token punctuation">;</span>//终止线程
    <span class="token punctuation">}</span>
</code></pre>
<h2 id="带参数的线程"><a href="#带参数的线程" class="headerlink" title="带参数的线程"></a>带参数的线程</h2><pre class=" language-bash"><code class="language-bash"> Thread thread <span class="token operator">=</span> new Thread<span class="token punctuation">((</span>a<span class="token punctuation">)</span> <span class="token operator">=</span><span class="token operator">></span> <span class="token punctuation">{</span>Console.WriteLine<span class="token punctuation">(</span><span class="token string">"参数{0}，{1}"</span>, a, Thread.CurrentThread.ManagedThreadId<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
 Thread thread <span class="token operator">=</span> new Thread<span class="token variable"><span class="token punctuation">((</span>a<span class="token punctuation">)</span> <span class="token operator">=</span><span class="token operator">></span> DoWork<span class="token punctuation">(</span>a<span class="token punctuation">))</span></span><span class="token punctuation">;</span>
 thread.IsBackground <span class="token operator">=</span> <span class="token boolean">true</span><span class="token punctuation">;</span>
 thread.Start<span class="token punctuation">(</span>2<span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
<h2 id="Demo异步委托"><a href="#Demo异步委托" class="headerlink" title="Demo异步委托"></a>Demo异步委托</h2><pre class=" language-bash"><code class="language-bash"> class Program
    <span class="token punctuation">{</span>
        public delegate void AddDel<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
               static void Main<span class="token punctuation">(</span>string<span class="token punctuation">[</span><span class="token punctuation">]</span> args<span class="token punctuation">)</span>
        <span class="token punctuation">{</span>   AddDel aa <span class="token operator">=</span> DoWork<span class="token punctuation">;</span>
            AddDel addDemo <span class="token operator">=</span> new AddDel<span class="token punctuation">(</span>aa<span class="token punctuation">)</span><span class="token punctuation">;</span>
            addDemo.BeginInvoke<span class="token punctuation">(</span>null, null<span class="token punctuation">)</span><span class="token punctuation">;</span>
            Console.ReadKey<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
     static void DoWork<span class="token punctuation">(</span><span class="token punctuation">)</span> 
     <span class="token punctuation">{</span>
      <span class="token keyword">while</span> <span class="token punctuation">(</span>true<span class="token punctuation">)</span>
      <span class="token punctuation">{</span>
          Console.WriteLine<span class="token punctuation">(</span><span class="token string">"子线程跑起:{0}"</span>,Thread.CurrentThread.ManagedThreadId<span class="token punctuation">)</span><span class="token punctuation">;</span>
          Thread.Sleep<span class="token punctuation">(</span>1000<span class="token punctuation">)</span><span class="token punctuation">;</span>
      <span class="token punctuation">}</span>
      //Console.WriteLine<span class="token punctuation">(</span><span class="token string">"子线程跑起:{0}"</span>,Thread.CurrentThread.ManagedThreadId<span class="token punctuation">)</span><span class="token punctuation">;</span>
     <span class="token punctuation">}</span>

    <span class="token punctuation">}</span>

</code></pre>
<h2 id="Demo摇号机"><a href="#Demo摇号机" class="headerlink" title="Demo摇号机"></a>Demo摇号机</h2><p><img src="/2019/01/15/duo-xian-cheng/1.jpg" alt="图1"></p>
<pre class=" language-bash"><code class="language-bash">using System<span class="token punctuation">;</span>
using System.Collections.Generic<span class="token punctuation">;</span>
using System.ComponentModel<span class="token punctuation">;</span>
using System.Data<span class="token punctuation">;</span>
using System.Drawing<span class="token punctuation">;</span>
using System.Linq<span class="token punctuation">;</span>
using System.Text<span class="token punctuation">;</span>
using System.Windows.Forms<span class="token punctuation">;</span>
using System.Threading<span class="token punctuation">;</span>

namespace 摇号机
<span class="token punctuation">{</span>  
    public partial class Form1 <span class="token keyword">:</span> Form
    <span class="token punctuation">{</span>
        List<span class="token operator">&lt;</span>Label<span class="token operator">></span> list <span class="token operator">=</span> new List<span class="token operator">&lt;</span>Label<span class="token operator">></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        public bool IsCreate <span class="token operator">=</span> <span class="token boolean">false</span><span class="token punctuation">;</span>
        public Form1<span class="token punctuation">(</span><span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            InitializeComponent<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            Control.CheckForIllegalCrossThreadCalls <span class="token operator">=</span> <span class="token boolean">false</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>

        private void Form1_Load<span class="token punctuation">(</span>object sender, EventArgs e<span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            list.Add<span class="token punctuation">(</span>this.label1<span class="token punctuation">)</span><span class="token punctuation">;</span> list.Add<span class="token punctuation">(</span>this.label2<span class="token punctuation">)</span><span class="token punctuation">;</span> list.Add<span class="token punctuation">(</span>this.label3<span class="token punctuation">)</span><span class="token punctuation">;</span>
            list.Add<span class="token punctuation">(</span>this.label4<span class="token punctuation">)</span><span class="token punctuation">;</span>list.Add<span class="token punctuation">(</span>this.label5<span class="token punctuation">)</span><span class="token punctuation">;</span>list.Add<span class="token punctuation">(</span>this.label6<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>

        private void btnStart_Click<span class="token punctuation">(</span>object sender, EventArgs e<span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span>IsCreate<span class="token punctuation">)</span>
            <span class="token punctuation">{</span>
                IsCreate <span class="token operator">=</span> <span class="token boolean">false</span><span class="token punctuation">;</span>
                btnStart.Text <span class="token operator">=</span> <span class="token string">"开始"</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
            <span class="token keyword">else</span> 
            <span class="token punctuation">{</span>
                this.btnStart.Text <span class="token operator">=</span> <span class="token string">"结束"</span><span class="token punctuation">;</span>
                IsCreate <span class="token operator">=</span> <span class="token boolean">true</span><span class="token punctuation">;</span>
                //启动一个线程 改变值
                ThreadStart start <span class="token operator">=</span> workRandom<span class="token punctuation">;</span>
                Thread thread <span class="token operator">=</span> new Thread<span class="token punctuation">(</span>start<span class="token punctuation">)</span><span class="token punctuation">;</span>

                thread.IsBackground <span class="token operator">=</span> <span class="token boolean">true</span><span class="token punctuation">;</span>
                thread.Start<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
        <span class="token punctuation">}</span>
        public  void workRandom<span class="token punctuation">(</span><span class="token punctuation">)</span> 
        <span class="token punctuation">{</span>
            Random random <span class="token operator">=</span> new Random<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">while</span> <span class="token punctuation">(</span>IsCreate<span class="token punctuation">)</span> 
            <span class="token punctuation">{</span>
                <span class="token keyword">for</span> <span class="token punctuation">(</span>int i <span class="token operator">=</span> 0<span class="token punctuation">;</span> i <span class="token operator">&lt;</span> 6<span class="token punctuation">;</span> i++<span class="token punctuation">)</span> 
                <span class="token punctuation">{</span>
                    list<span class="token punctuation">[</span>i<span class="token punctuation">]</span>.Text <span class="token operator">=</span> random.Next<span class="token punctuation">(</span>0, 10<span class="token punctuation">)</span>.ToString<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token punctuation">}</span>
                Thread.Sleep<span class="token punctuation">(</span>100<span class="token punctuation">)</span><span class="token punctuation">;</span>  
            <span class="token punctuation">}</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>

            </div>
            <hr>

            
            <style>
    #reward {
        margin: 40px 0;
        text-align: center;
    }

    #reward .reward-link {
        font-size: 1.88rem;
    }

    #reward .btn-floating:hover {
        box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2), 0 5px 15px rgba(0, 0, 0, 0.2);
    }

    #rewardModal {
        width: 320px;
        height: 350px;
    }

    #rewardModal .reward-title {
        margin: 15px auto;
        padding-bottom: 5px;
    }

    #rewardModal .modal-content {
        padding: 10px;
    }

    #rewardModal .close {
        position: absolute;
        right: 15px;
        top: 15px;
        color: rgba(0, 0, 0, 0.5);
        font-size: 1.3rem;
        line-height: 20px;
        cursor: pointer;
    }

    #rewardModal .reward-tabs {
        margin: 0 auto;
        width: 210px;
    }

    .reward-tabs .tabs {
        height: 38px;
        margin: 10px auto;
        padding-left: 0;
    }

    .reward-tabs .tabs .tab {
        height: 38px;
        line-height: 38px;
    }

    .reward-tabs .tab a {
        color: #fff;
        background-color: #ccc;
    }

    .reward-tabs .tab a:hover {
        color: #fff;
    }

    .reward-tabs .wechat-tab .active {
        color: #fff;
        background-color: #22AB38;
    }

    .reward-tabs .alipay-tab .active {
        color: #fff;
        background-color: #019FE8;
    }

    .reward-tabs .reward-img {
        width: 210px;
        height: 210px;
    }
</style>

<div id="reward">
    <a class="reward-link btn-floating btn-large waves-effect waves-light red">赏</a>

    <!-- Modal Structure -->
    <div id="rewardModal" class="modal">
        <div class="modal-content">
            <a class="close"><i class="fa fa-close"></i></a>
            <h4 class="reward-title">你的赏识是我前进的动力</h4>
            <div class="reward-content">
                <div class="reward-tabs">
                    <ul class="tabs">
                        <li class="tab wechat-tab waves-effect waves-light"><a class="active" href="#wechat">微信</a></li>
                        <li class="tab alipay-tab waves-effect waves-light"><a href="#alipay">支付宝</a></li>
                    </ul>
                    <div id="wechat">
                        <img src="/medias/reward/wechat.png" class="reward-img" alt="微信打赏二维码">
                    </div>
                    <div id="alipay">
                        <img src="/medias/reward/alipay.jpg" class="reward-img" alt="支付宝打赏二维码">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    $(function () {
        $('#reward .reward-link').on('click', function () {
            $('#rewardModal').openModal();
        });

        $('#rewardModal .close').on('click', function () {
            $('#rewardModal').closeModal();
        });
    });
</script>
            

            <link rel="stylesheet" type="text/css" href="/libs/share/css/share.min.css">

<div id="article-share">
    
    <div class="social-share" data-disabled="qzone" data-wechat-qrcode-helper="<p>微信里点“发现”->“扫一扫”二维码便可查看分享。</p>"></div>
    
</div>

<script src="/libs/share/js/social-share.min.js"></script>

            <div class="reprint">
                <p>
                    <span class="reprint-tip">转载请注明: </span>
                    <a href="https://zy20081.github.io" class="b-link-green">Zhou•Yong</a>
                    <i class="fa fa-angle-right fa-lg fa-fw text-color"></i>
                    <a href="/2019/01/15/duo-xian-cheng/" class="b-link-green">多线程</a>
                </p>
            </div>
        </div>
    </div>

    

    

    

    

    

    

<article id="prenext-posts" class="prev-next articles">
    <div class="row article-row">
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge left-badge text-color">上一篇</div>
            <div class="card">
                <a href="/2019/01/15/di-gui-vs-xun-huan/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/2.jpg" class="responsive-img" alt="递归VS循环">
                        
                        <span class="card-title">递归VS循环</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary">递归VS循环求第三位数前2位之和 ，一列数的规则如下: 1、1、2、3
 class Program
    {
        static void Main(string[] args)
        {
            w</div>
                    <div class="publish-info">
                        <span class="publish-date">
                            <i class="fa fa-clock-o fa-fw icon-date"></i>2019-01-15
                        </span>
                        <span class="publish-author">
                            
                            <i class="fa fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/categories/C/" class="post-category" target="_blank">
                                    C#
                                </a>
                            
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/tags/C-基础知识/" target="_blank">
                        <span class="chip bg-color">C# 基础知识</span>
                    </a>
                    
                    <a href="/tags/C/" target="_blank">
                        <span class="chip bg-color">C#</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge right-badge text-color">下一篇</div>
            <div class="card">
                <a href="/2019/01/15/fan-she/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/15.jpg" class="responsive-img" alt="反射">
                        
                        <span class="card-title">反射</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary">反射定义一个类，并且生成dllusing System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ClassLib</div>
                    <div class="publish-info">
                            <span class="publish-date">
                                <i class="fa fa-clock-o fa-fw icon-date"></i>2019-01-15
                            </span>
                        <span class="publish-author">
                            
                            <i class="fa fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/categories/C/" class="post-category" target="_blank">
                                    C#
                                </a>
                            
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/tags/C-基础知识/" target="_blank">
                        <span class="chip bg-color">C# 基础知识</span>
                    </a>
                    
                    <a href="/tags/C/" target="_blank">
                        <span class="chip bg-color">C#</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
    </div>
</article>
</div>


    </div>
    <div class="col l3 hide-on-med-and-down">
        <div class="toc-widget">
            <div class="toc-title">目录</div>
            <div id="toc-content">

            </div>
        </div>
    </div>
</div>

<script src="/libs/tocbot/tocbot.min.js"></script>
<script>
    $(function () {
        tocbot.init({
            tocSelector: '#toc-content',
            contentSelector: '#articleContent',
            headingSelector: 'h2, h3, h4'
        });

        // modify the toc link href to support Chinese.
        let i = 0;
        let tocHeading = 'toc-heading-';
        $('#toc-content a').each(function () {
            $(this).attr('href', '#' + tocHeading + (++i));
        });

        // modify the heading title id to support Chinese.
        i = 0;
        $('#articleContent').children('h2, h3, h4').each(function () {
            $(this).attr('id', tocHeading + (++i));
        });

        // Set scroll toc fixed.
        let tocHeight = parseInt($(window).height() * 0.4 - 64);
        let $tocWidget = $('.toc-widget');
        $(window).scroll(function () {
            let scroll = $(window).scrollTop();
            /* add post toc fixed. */
            if (scroll > tocHeight) {
                $tocWidget.addClass('toc-fixed');
            } else {
                $tocWidget.removeClass('toc-fixed');
            }
        });
    });
</script>
    

</main>


<footer class="page-footer bg-color">
    <div class="container row center-align">
        <div class="col s12 m8 l8 copy-right">
            本站由ZhouYong 技术分享，心得分享.
        </div>
        <div class="col s12 m4 l4 social-link"><a href="#!" class="tooltipped" data-tooltip="邮件联系我: zy20081@126.com" data-position="top" data-delay="50">
    <i class="fa fa-envelope-open"></i>
</a>
<a href="#!" class="tooltipped" data-tooltip="QQ联系我: 314153271" data-position="top" data-delay="50">
    <i class="fa fa-qq"></i>
</a>

<a href="/atom.xml" class="tooltipped" target="_blank" data-tooltip="RSS 订阅" data-position="top" data-delay="50">
    <i class="fa fa-rss"></i>
</a>
</div>
    </div>
</footer>

<div class="progress-bar"></div>


<!-- 搜索遮罩框 -->
<div id="searchModal" class="modal">
    <div class="modal-content">
        <div class="search-header">
            <span class="title">搜索</span>
            <input type="search" id="searchInput" name="s" placeholder="请输入搜索的关键字" class="search-input" autofocus>
        </div>
        <div id="searchResult"></div>
    </div>
</div>

<script src="/js/search.js"></script>
<script type="text/javascript">
    searchFunc("/" + "search.xml", 'searchInput', 'searchResult');
</script>
<!-- 回到顶部按钮 -->
<div id="backTop" class="top-scroll">
    <a class="btn-floating btn-large waves-effect waves-light" href="#!">
        <i class="fa fa-angle-up"></i>
    </a>
</div>


<script src="/libs/materialize/js/materialize.min.js"></script>
<script src="/libs/masonry/masonry.pkgd.min.js"></script>
<script src="/libs/aos/aos.js"></script>
<script src="/libs/scrollprogress/scrollProgress.min.js"></script>
<script src="/libs/lightGallery/js/lightgallery-all.min.js"></script>

<script src="/libs/others/clicklove.js"></script>

<script src="/js/matery.js"></script>
<!-- Global site tag (gtag.js) - Google Analytics -->


</body>
</html>